package com.sample.action;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sample.action.form.GgaoForm;
import com.sample.javabean.Ggao;
import com.sample.util.Pager;

     /**
     * @author梁桂花
     *
     * 2018-10-24
     */
           public class GgaoAction extends BaseAction {
    	 
      
    	   private final static Log log=LogFactory.getLog(GgaoAction.class);
    	 	private Pager<Ggao> pageList;
    	 	private Integer id;
    	 	private Ggao ggao=new Ggao();
    	 	private GgaoForm ggaoForm=new GgaoForm();
    	 	
    	 	
    	 	/**
    	 	 * 公告信息录入界面
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String inputGgao()throws Exception{
    	 		
    	 		return "inputGgao";
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String save()throws Exception{
    	 		try{
    	 			log.info("添加公告信息");
    	 			if(ggaoForm!=null){
    	 				Ggao ggao =new Ggao();
    	 				 //将ggaoForm中的属性值一一对应ggao的对应属性
    	 				ggao.setNews(ggaoForm.getNews());
    	 				ggao.setPerson(ggaoForm.getPerson());
    	 				ggao.setPosttime(ggaoForm.getPosttime());
    	 				
    	 				
    	 			   //调用方法
    	 				ggao.add();
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			
    	 		}
    	 		return "inputGgao";
    	 	}
    	 	
    	 	public String list()throws Exception{
    	 		Ggao ggaoModel =new Ggao();
    	 		pageList =ggaoModel.list(page, size, ggaoForm);
    	 		return "listGgao";
    	 	}
    	 	public String del()throws Exception{
    	 		try{
    	 			if(ggaoForm!=null){
    	 				ggao.setId(id);
    	 				ggao.delGgao();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	public String editGgao()throws Exception{
    	 		try{
    	 			ggao.setId(id);
    	 			ggao.load();
    	 			return "editGgao";
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String edit()throws Exception{
    	 		log.info("sss");
    	 		try{
    	 			
    	 			if(ggaoForm!=null){
    	 				ggao.setId(ggaoForm.getId());	
    	 				
    	 				ggao.setNews(ggaoForm.getNews());
    	 			
    	 				ggao.setPerson(ggaoForm.getPerson());
    	 				
    	 				ggao.setPosttime(ggaoForm.getPosttime());
    	 			
    	 				
    	 				
    	 				ggao.editGgao();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
			public Pager<Ggao> getPageList() {
				return pageList;
			}
			public void setPageList(Pager<Ggao> pageList) {
				this.pageList = pageList;
			}
			public Integer getId() {
				return id;
			}
			public void setId(Integer id) {
				this.id = id;
			}
			public Ggao getGgao() {
				return ggao;
			}
			public void setGgao(Ggao ggao) {
				this.ggao = ggao;
			}
			public GgaoForm getGgaoForm() {
				return ggaoForm;
			}
			public void setGgaoForm(GgaoForm ggaoForm) {
				this.ggaoForm = ggaoForm;
			}
			public static Log getLog() {
				return log;
			}
			
			
    	
}
